﻿using System;
using System.ComponentModel;
using System.Web.UI;
using System.Collections;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class ZiCaiInfoDetail : YuanlinUserControl,
        IReplyConverter<ZiCaiInfoReply, GetOperation>
    {
        protected Repeater list;
        private ZiCaiInfo ziCaiInfo;

        public override void GetRequests(List<BaseRequestBinder> requestBinders)
        {
            if (!Page.IsPostBack)
            {
                requestBinders.Add(RequestHelper.BuildGetZiCaiInfoRequest(this));
            }
        }

        private void BindData()
        {
            EntityList ziCaiInfos = new EntityList()  ;

            if (ziCaiInfo != null)
            {
                ziCaiInfos.Add(ziCaiInfo);
            }

            list.DataSource = ziCaiInfos;
            list.DataBind();
        }

        #region IReplyConverter<ZiCaiInfoReply,GetOperation> Members

        public void ConvertReply(ZiCaiInfoReply reply, GetOperation operation)
        {
            if (reply != null)
            {
                ziCaiInfo = reply.Entity as ZiCaiInfo;
                if (!Page.IsPostBack)
                {
                    BindData();
                }
            }
        }

        #endregion
    }
}
